package com.sm.tools;

import com.sm.R;
import com.sm.R.layout;
import com.sm.R.menu;
import com.sm.bo.Course;
import com.sm.bo.Student;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class NewModifyCourseActivity extends Activity {
	EditText courseCode;
	EditText courseWording;
	Button createOrModifieCourse;
	Button cancelCourse;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_new_course);

		Bundle extras = getIntent().getExtras();
		if (extras == null) {
			return;
		}

		courseCode = (EditText) findViewById(R.id.txt_Course_Code);
		courseWording = (EditText) findViewById(R.id.txt_Course_Wording);
		createOrModifieCourse = (Button) findViewById(R.id.btn_Create_Course);
		cancelCourse = (Button) findViewById(R.id.btn_Cancel_Course);

		String NewOrModify = extras.getString("NewOrModify");
		if (NewOrModify != null && NewOrModify.equals("New")) {
			createOrModifieCourse.setText("Create");
			this.setTitle("New Course");
		} else if (NewOrModify != null && NewOrModify.equals("Modify")) {
			createOrModifieCourse.setText("Save");
			this.setTitle("Modify Course");

			Course course = getIntent().getExtras().getParcelable("course");
			courseCode.setText(course.getCode());
			courseWording.setText(course.getWording());
		}

		cancelCourse.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	@Override
	public void finish() {
		super.finish();
	}

}
